import React from 'react';
//react-fileupload是github上已有的组件，先yarn add 安装，由于该组件使用的react版本与该项项目组件冲突
//我们将react-fileupload组件重写到tool/file-upload/react-fileupload.jsx,再引入
import FileUpload  from './react-fileupload.jsx';

class FileUploader extends React.Component{

render(){
	const options={
    baseUrl: '/manage/product/upload.do',
    dataType: 'json',
    fileFieldName: 'upload_file',
    chooseAndUpload: true,
    uploadSuccess: (res) =>{
      this.props.onSuccess(res.data)
    },
    uploadError: (err) =>{
      this.props.onError(err.message)
    }

	}
	return (
    <div>
        <FileUpload options={options}>
          <button ref="chooseAndUpload">添加图片</button>
        </FileUpload>
    </div>
	)	        
 }
}
export default FileUploader;